//
//  BottomTool.m
//  WuJieLive
//
//  Created by iMac on 2017/11/15.
//  Copyright © 2017年 zhk. All rights reserved.
//

#import "BottomTool.h"

@implementation BottomTool

- (void)awakeFromNib {
    [super awakeFromNib];
    self.collectionBtn = [[HKButton alloc]init];
    [self.leftBtnBgView addSubview:self.collectionBtn];
    [self.collectionBtn setImage:Image(@"icon_tab_收藏") forState:(UIControlStateNormal)];
    self.collectionBtn.titleLabel.font = FontSize(10);
    [self.collectionBtn setTitle:@"收藏" forState:(UIControlStateNormal)];
    [self.collectionBtn setTitleColor:TextAssistColor forState:(UIControlStateNormal)];
    [self.collectionBtn addTarget:self action:@selector(collectionAction) forControlEvents:(UIControlEventTouchUpInside)];
    [self.collectionBtn setTitle:@"已收藏" forState:(UIControlStateSelected)];
    [self.collectionBtn setImage:Image(@"icon_tab_已收藏") forState:(UIControlStateSelected)];
    
    self.cartBtn = [[HKButton alloc]init];
    [self.leftBtnBgView addSubview:self.cartBtn];
    [self.cartBtn setImage:Image(@"icon_nav_购物车") forState:(UIControlStateNormal)];
    self.cartBtn.titleLabel.font = FontSize(10);
    [self.cartBtn setTitle:@"购物车" forState:(UIControlStateNormal)];
    [self.cartBtn setTitleColor:TextAssistColor forState:(UIControlStateNormal)];
    [self.cartBtn addTarget:self action:@selector(takeInCartAction) forControlEvents:(UIControlEventTouchUpInside)];
    
    [self.collectionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.top.bottom.offset(0);
        make.width.offset((self.leftBtnBgView.width - 30) / 2.5);
    }];
    
    [self.cartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-10);
        make.top.bottom.offset(0);
        make.width.offset((self.leftBtnBgView.width - 30) / 2.5);
    }];
}

- (void)collectionAction
{
    if (self.collectBlock) {
        self.collectBlock();
    }
}

- (void)takeInCartAction
{
    if (self.cartBlock) {
        self.cartBlock();
    }
}
- (IBAction)takeInCartAction:(id)sender {
    if (self.takeInCartBlock) {
        self.takeInCartBlock();
    }
}
- (IBAction)buyNowAction:(id)sender {
    if (self.buyNowBlock) {
        self.buyNowBlock();
    }
}

@end
